﻿// <copyright file="FirewallRule.cs" company="Beuth Hochschule für Technik">
// Breakdown - Configure your Windows 7 Firewall
// Copyright (C) 2009 Stefan "dersteps@gmail.com" Matyba
// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; 
// either version 3 of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/.
// </copyright>
// <author>Stefan Matyba</author>
// <email>dersteps@gmail.com</email>
// <date>2009-10-18</date>
// <summary>Breakdown Application Logic - Implementation of a firewall rule</summary>

namespace Breakdown.Logic
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Breakdown.Aspects;
    using Ninject.Core;

    /// <summary>
    /// Represents a firewall rule
    /// </summary>
    [Logged]
    public class FirewallRule : ARule
    {
        /// <summary>
        /// Firewall rules can affect certain interface types only, which is expressed by this element
        /// </summary>
        private IInterfaceAffector _interfaceAffector;

        /// <summary>
        /// Firewall rules can affect certain IP addresss only, which is expressed by this element
        /// </summary>
        private IScoped _scope;

        /// <summary>
        /// Firewall rules can affect either all or just a single executable file, which is expressed by this element
        /// </summary>
        private IProgramAffector _programAffector;

        /// <summary>
        /// Firewall rules can affect either all or just a single system service, which is expressed by this element
        /// </summary>
        private IServiceAffector _serviceAffector;

        /// <summary>
        /// Initializes a new instance of the FirewallRule class
        /// </summary>
        public FirewallRule()
        {
        }

        /// <summary>
        /// Gets or sets the IInterfaceAffector that is part of this rule
        /// </summary>
        [Inject]
        public override IInterfaceAffector InterfaceAffector
        {
            get { return this._interfaceAffector; }
            set
            { 
                this._interfaceAffector = value;
                this.Notify();
            }
        }

        /// <summary>
        /// Gets or sets the IScoped that is part of this rule
        /// </summary>
        [Inject]
        public override IScoped Scope
        {
            get { return this._scope; }
            set
            { 
                this._scope = value;
                this.Notify();
            }
        }

        /// <summary>
        /// Gets or sets the IProgramAffector that is part of this rule
        /// </summary>
        [Inject]
        public override IProgramAffector ProgramAffector
        {
            get { return this._programAffector; }
            set
            {
                this._programAffector = value;
                this.Notify();
            }
        }

        /// <summary>
        /// Gets or sets the IServiceAffector that is part of this rule
        /// </summary>
        [Inject]
        public override IServiceAffector ServiceAffector
        {
            get { return this._serviceAffector; }
            set 
            { 
                this._serviceAffector = value;
                this.Notify();
            }
        }
    }
}
